package com.aya.aopx.invalid;

import com.aya.aopx.invalid.service.TxFailService;
import com.aya.aopx.invalid.service.TxSuccessService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * HttpServletResponse 两种方式注入的线程安全演示
 */
@Controller
public class ResponseController {

    @Resource
    private TxSuccessService txSuccessService;

    @Resource
    private TxFailService txFailService;

    @ResponseBody
    @RequestMapping("tx/success")
    public String success() throws IOException {
        txSuccessService.cat();
        return "success";
    }

    @ResponseBody
    @RequestMapping("tx/fail")
    public String fail() throws IOException {
        txFailService.cat();
        return "fail";
    }
}
